package com.example.demo.service;

import com.example.demo.entity.CreditCardApplyInfo;
import org.kie.api.KieBase;
import org.kie.api.runtime.KieSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author lizhien (zhien.li@nascent.cn)
 * @Date 2020/8/4 19:47
 * @Version 1.0.0
 * @Description com.example.demo
 */

@Service
public class RuleService {

    @Autowired
    private KieBase kieBase;

    //调用Drools规则引擎实现信用卡申请
    public CreditCardApplyInfo creditCardApply(CreditCardApplyInfo creditCardApplyInfo) {
        KieSession session = kieBase.newKieSession();        //获取KieSession
        session.insert(creditCardApplyInfo);              //插入
        session.fireAllRules();                           //执行规则
        session.dispose();                                //释放资源
        return creditCardApplyInfo;
    }
}
